package com.app.view.component.dialogs.pkResultView 
{
	import flash.display.MovieClip;
	import flash.text.TextField;
	
	import org.component.item.ListItem;
	import org.component.interfaces.IListItemData;
	
	import com.app.model.data.PaijiuTypeItemData;
	
	import com.app.view.component.room.seat.Paijiu;
	
	/**
	 * ...
	 * @author kevin
	 */
	public class PaijiuTypeListItem extends ListItem
	{
		private var _txtRank:TextField = null;
		
		private var _firstPaijiu:MovieClip = null;
		
		private var _secondPaijiu:MovieClip = null;
		
		private var _txtTitle:TextField = null;
		
		public function PaijiuTypeListItem(ui:MovieClip = null) 
		{
			super(ui);
		}
		
		override protected function initialization():void 
		{
			super.initialization();
			
			_txtRank = assest["txt_rank"];
			_txtTitle = assest["txt_title"];
			
			_firstPaijiu = assest["mc_first_paijiu"];
			_secondPaijiu = assest["mc_second_paijiu"];
		}
		
		override public function update(data:IListItemData = null):void 
		{
			super.update(null);
			
			_txtRank.text = String(PaijiuTypeItemData(data).rank);
			_txtTitle.text = PaijiuTypeItemData(data).title;

			showPaijiu(_firstPaijiu["pai_number"], PaijiuTypeItemData(data).paijiu_1);
			showPaijiu(_secondPaijiu["pai_number"], PaijiuTypeItemData(data).paijiu_2);
		}
		
		private function showPaijiu(mc:MovieClip, data:int):void
		{
			for (var key:* in Paijiu.PAIJIU)
			{
				if (Paijiu.PAIJIU[key] == data)
				{
					mc.gotoAndStop(key + 1);
				}
			}
		}
		
		public function setScale(s:Number):void
		{
			assest.scaleX = s;
			assest.scaleY = s;
		}
	}

}